﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using jnxc.DBUtility;//Please add references
namespace jnxc.DAL
{
	/// <summary>
	/// 数据访问类:addprevention
	/// </summary>
	public partial class addprevention
	{
		public addprevention()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("apid", "addprevention"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int apid)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from addprevention");
			strSql.Append(" where apid=@apid");
			SqlParameter[] parameters = {
					new SqlParameter("@apid", SqlDbType.Int,4)
			};
			parameters[0].Value = apid;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(jnxc.Model.addprevention model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into addprevention(");
			strSql.Append("aid,dpid,trees,shouldarea,jzarea,jcarea,generation,dctime,dckdgarea,fbarea,sdlj,ljqd,ljzd,ljzzd,fssum,fsqd,fszd,fszzd,tbcnew,yjzh,fsrate,fztime,workarea,wghwork,zja,xja,bda,fla,qttda,zwyyja,qtsfa,fsfza,wghhfa,wlfza,rgfza,qtfza,qtwgha,hxfza,fzsum,yfarea,ffarea,zjb,xjb,bdb,flb,qttdb,qtsfb,fsb,rgb,qtfzb,hfb,tbcxfz,wghfzrate,fzrate,czarea,whzharea,czrate,fzfy,sszs,zjl,xjl,bdl,tdkc,fsyl,yjll,jzll,yjl,hxqt,uid)");
			strSql.Append(" values (");
			strSql.Append("@aid,@dpid,@trees,@shouldarea,@jzarea,@jcarea,@generation,@dctime,@dckdgarea,@fbarea,@sdlj,@ljqd,@ljzd,@ljzzd,@fssum,@fsqd,@fszd,@fszzd,@tbcnew,@yjzh,@fsrate,@fztime,@workarea,@wghwork,@zja,@xja,@bda,@fla,@qttda,@zwyyja,@qtsfa,@fsfza,@wghhfa,@wlfza,@rgfza,@qtfza,@qtwgha,@hxfza,@fzsum,@yfarea,@ffarea,@zjb,@xjb,@bdb,@flb,@qttdb,@qtsfb,@fsb,@rgb,@qtfzb,@hfb,@tbcxfz,@wghfzrate,@fzrate,@czarea,@whzharea,@czrate,@fzfy,@sszs,@zjl,@xjl,@bdl,@tdkc,@fsyl,@yjll,@jzll,@yjl,@hxqt,@uid)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@aid", SqlDbType.Int,4),
					new SqlParameter("@dpid", SqlDbType.Int,4),
					new SqlParameter("@trees", SqlDbType.NVarChar,20),
					new SqlParameter("@shouldarea", SqlDbType.Decimal,9),
					new SqlParameter("@jzarea", SqlDbType.Decimal,9),
					new SqlParameter("@jcarea", SqlDbType.Decimal,9),
					new SqlParameter("@generation", SqlDbType.Int,4),
					new SqlParameter("@dctime", SqlDbType.DateTime),
					new SqlParameter("@dckdgarea", SqlDbType.Decimal,9),
					new SqlParameter("@fbarea", SqlDbType.Decimal,9),
					new SqlParameter("@sdlj", SqlDbType.Decimal,9),
					new SqlParameter("@ljqd", SqlDbType.Decimal,9),
					new SqlParameter("@ljzd", SqlDbType.Decimal,9),
					new SqlParameter("@ljzzd", SqlDbType.Decimal,9),
					new SqlParameter("@fssum", SqlDbType.Decimal,9),
					new SqlParameter("@fsqd", SqlDbType.Decimal,9),
					new SqlParameter("@fszd", SqlDbType.Decimal,9),
					new SqlParameter("@fszzd", SqlDbType.Decimal,9),
					new SqlParameter("@tbcnew", SqlDbType.Decimal,9),
					new SqlParameter("@yjzh", SqlDbType.Decimal,9),
					new SqlParameter("@fsrate", SqlDbType.Decimal,9),
					new SqlParameter("@fztime", SqlDbType.DateTime),
					new SqlParameter("@workarea", SqlDbType.Decimal,9),
					new SqlParameter("@wghwork", SqlDbType.Decimal,9),
					new SqlParameter("@zja", SqlDbType.Decimal,9),
					new SqlParameter("@xja", SqlDbType.Decimal,9),
					new SqlParameter("@bda", SqlDbType.Decimal,9),
					new SqlParameter("@fla", SqlDbType.Decimal,9),
					new SqlParameter("@qttda", SqlDbType.Decimal,9),
					new SqlParameter("@zwyyja", SqlDbType.Decimal,9),
					new SqlParameter("@qtsfa", SqlDbType.Decimal,9),
					new SqlParameter("@fsfza", SqlDbType.Decimal,9),
					new SqlParameter("@wghhfa", SqlDbType.Decimal,9),
					new SqlParameter("@wlfza", SqlDbType.Decimal,9),
					new SqlParameter("@rgfza", SqlDbType.Decimal,9),
					new SqlParameter("@qtfza", SqlDbType.Decimal,9),
					new SqlParameter("@qtwgha", SqlDbType.Decimal,9),
					new SqlParameter("@hxfza", SqlDbType.Decimal,9),
					new SqlParameter("@fzsum", SqlDbType.Decimal,9),
					new SqlParameter("@yfarea", SqlDbType.Decimal,9),
					new SqlParameter("@ffarea", SqlDbType.Decimal,9),
					new SqlParameter("@zjb", SqlDbType.Decimal,9),
					new SqlParameter("@xjb", SqlDbType.Decimal,9),
					new SqlParameter("@bdb", SqlDbType.Decimal,9),
					new SqlParameter("@flb", SqlDbType.Decimal,9),
					new SqlParameter("@qttdb", SqlDbType.Decimal,9),
					new SqlParameter("@qtsfb", SqlDbType.Decimal,9),
					new SqlParameter("@fsb", SqlDbType.Decimal,9),
					new SqlParameter("@rgb", SqlDbType.Decimal,9),
					new SqlParameter("@qtfzb", SqlDbType.Decimal,9),
					new SqlParameter("@hfb", SqlDbType.Decimal,9),
					new SqlParameter("@tbcxfz", SqlDbType.Decimal,9),
					new SqlParameter("@wghfzrate", SqlDbType.Decimal,9),
					new SqlParameter("@fzrate", SqlDbType.Decimal,9),
					new SqlParameter("@czarea", SqlDbType.Decimal,9),
					new SqlParameter("@whzharea", SqlDbType.Decimal,9),
					new SqlParameter("@czrate", SqlDbType.Decimal,9),
					new SqlParameter("@fzfy", SqlDbType.Decimal,9),
					new SqlParameter("@sszs", SqlDbType.Int,4),
					new SqlParameter("@zjl", SqlDbType.Decimal,9),
					new SqlParameter("@xjl", SqlDbType.Decimal,9),
					new SqlParameter("@bdl", SqlDbType.Decimal,9),
					new SqlParameter("@tdkc", SqlDbType.Decimal,9),
					new SqlParameter("@fsyl", SqlDbType.Decimal,9),
					new SqlParameter("@yjll", SqlDbType.Decimal,9),
					new SqlParameter("@jzll", SqlDbType.Decimal,9),
					new SqlParameter("@yjl", SqlDbType.Decimal,9),
					new SqlParameter("@hxqt", SqlDbType.Decimal,9),
					new SqlParameter("@uid", SqlDbType.Int,4)};
			parameters[0].Value = model.aid;
			parameters[1].Value = model.dpid;
			parameters[2].Value = model.trees;
			parameters[3].Value = model.shouldarea;
			parameters[4].Value = model.jzarea;
			parameters[5].Value = model.jcarea;
			parameters[6].Value = model.generation;
			parameters[7].Value = model.dctime;
			parameters[8].Value = model.dckdgarea;
			parameters[9].Value = model.fbarea;
			parameters[10].Value = model.sdlj;
			parameters[11].Value = model.ljqd;
			parameters[12].Value = model.ljzd;
			parameters[13].Value = model.ljzzd;
			parameters[14].Value = model.fssum;
			parameters[15].Value = model.fsqd;
			parameters[16].Value = model.fszd;
			parameters[17].Value = model.fszzd;
			parameters[18].Value = model.tbcnew;
			parameters[19].Value = model.yjzh;
			parameters[20].Value = model.fsrate;
			parameters[21].Value = model.fztime;
			parameters[22].Value = model.workarea;
			parameters[23].Value = model.wghwork;
			parameters[24].Value = model.zja;
			parameters[25].Value = model.xja;
			parameters[26].Value = model.bda;
			parameters[27].Value = model.fla;
			parameters[28].Value = model.qttda;
			parameters[29].Value = model.zwyyja;
			parameters[30].Value = model.qtsfa;
			parameters[31].Value = model.fsfza;
			parameters[32].Value = model.wghhfa;
			parameters[33].Value = model.wlfza;
			parameters[34].Value = model.rgfza;
			parameters[35].Value = model.qtfza;
			parameters[36].Value = model.qtwgha;
			parameters[37].Value = model.hxfza;
			parameters[38].Value = model.fzsum;
			parameters[39].Value = model.yfarea;
			parameters[40].Value = model.ffarea;
			parameters[41].Value = model.zjb;
			parameters[42].Value = model.xjb;
			parameters[43].Value = model.bdb;
			parameters[44].Value = model.flb;
			parameters[45].Value = model.qttdb;
			parameters[46].Value = model.qtsfb;
			parameters[47].Value = model.fsb;
			parameters[48].Value = model.rgb;
			parameters[49].Value = model.qtfzb;
			parameters[50].Value = model.hfb;
			parameters[51].Value = model.tbcxfz;
			parameters[52].Value = model.wghfzrate;
			parameters[53].Value = model.fzrate;
			parameters[54].Value = model.czarea;
			parameters[55].Value = model.whzharea;
			parameters[56].Value = model.czrate;
			parameters[57].Value = model.fzfy;
			parameters[58].Value = model.sszs;
			parameters[59].Value = model.zjl;
			parameters[60].Value = model.xjl;
			parameters[61].Value = model.bdl;
			parameters[62].Value = model.tdkc;
			parameters[63].Value = model.fsyl;
			parameters[64].Value = model.yjll;
			parameters[65].Value = model.jzll;
			parameters[66].Value = model.yjl;
			parameters[67].Value = model.hxqt;
			parameters[68].Value = model.uid;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(jnxc.Model.addprevention model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update addprevention set ");
			strSql.Append("aid=@aid,");
			strSql.Append("dpid=@dpid,");
			strSql.Append("trees=@trees,");
			strSql.Append("shouldarea=@shouldarea,");
			strSql.Append("jzarea=@jzarea,");
			strSql.Append("jcarea=@jcarea,");
			strSql.Append("generation=@generation,");
			strSql.Append("dctime=@dctime,");
			strSql.Append("dckdgarea=@dckdgarea,");
			strSql.Append("fbarea=@fbarea,");
			strSql.Append("sdlj=@sdlj,");
			strSql.Append("ljqd=@ljqd,");
			strSql.Append("ljzd=@ljzd,");
			strSql.Append("ljzzd=@ljzzd,");
			strSql.Append("fssum=@fssum,");
			strSql.Append("fsqd=@fsqd,");
			strSql.Append("fszd=@fszd,");
			strSql.Append("fszzd=@fszzd,");
			strSql.Append("tbcnew=@tbcnew,");
			strSql.Append("yjzh=@yjzh,");
			strSql.Append("fsrate=@fsrate,");
			strSql.Append("fztime=@fztime,");
			strSql.Append("workarea=@workarea,");
			strSql.Append("wghwork=@wghwork,");
			strSql.Append("zja=@zja,");
			strSql.Append("xja=@xja,");
			strSql.Append("bda=@bda,");
			strSql.Append("fla=@fla,");
			strSql.Append("qttda=@qttda,");
			strSql.Append("zwyyja=@zwyyja,");
			strSql.Append("qtsfa=@qtsfa,");
			strSql.Append("fsfza=@fsfza,");
			strSql.Append("wghhfa=@wghhfa,");
			strSql.Append("wlfza=@wlfza,");
			strSql.Append("rgfza=@rgfza,");
			strSql.Append("qtfza=@qtfza,");
			strSql.Append("qtwgha=@qtwgha,");
			strSql.Append("hxfza=@hxfza,");
			strSql.Append("fzsum=@fzsum,");
			strSql.Append("yfarea=@yfarea,");
			strSql.Append("ffarea=@ffarea,");
			strSql.Append("zjb=@zjb,");
			strSql.Append("xjb=@xjb,");
			strSql.Append("bdb=@bdb,");
			strSql.Append("flb=@flb,");
			strSql.Append("qttdb=@qttdb,");
			strSql.Append("qtsfb=@qtsfb,");
			strSql.Append("fsb=@fsb,");
			strSql.Append("rgb=@rgb,");
			strSql.Append("qtfzb=@qtfzb,");
			strSql.Append("hfb=@hfb,");
			strSql.Append("tbcxfz=@tbcxfz,");
			strSql.Append("wghfzrate=@wghfzrate,");
			strSql.Append("fzrate=@fzrate,");
			strSql.Append("czarea=@czarea,");
			strSql.Append("whzharea=@whzharea,");
			strSql.Append("czrate=@czrate,");
			strSql.Append("fzfy=@fzfy,");
			strSql.Append("sszs=@sszs,");
			strSql.Append("zjl=@zjl,");
			strSql.Append("xjl=@xjl,");
			strSql.Append("bdl=@bdl,");
			strSql.Append("tdkc=@tdkc,");
			strSql.Append("fsyl=@fsyl,");
			strSql.Append("yjll=@yjll,");
			strSql.Append("jzll=@jzll,");
			strSql.Append("yjl=@yjl,");
			strSql.Append("hxqt=@hxqt,");
			strSql.Append("uid=@uid");
			strSql.Append(" where apid=@apid");
			SqlParameter[] parameters = {
					new SqlParameter("@aid", SqlDbType.Int,4),
					new SqlParameter("@dpid", SqlDbType.Int,4),
					new SqlParameter("@trees", SqlDbType.NVarChar,20),
					new SqlParameter("@shouldarea", SqlDbType.Decimal,9),
					new SqlParameter("@jzarea", SqlDbType.Decimal,9),
					new SqlParameter("@jcarea", SqlDbType.Decimal,9),
					new SqlParameter("@generation", SqlDbType.Int,4),
					new SqlParameter("@dctime", SqlDbType.DateTime),
					new SqlParameter("@dckdgarea", SqlDbType.Decimal,9),
					new SqlParameter("@fbarea", SqlDbType.Decimal,9),
					new SqlParameter("@sdlj", SqlDbType.Decimal,9),
					new SqlParameter("@ljqd", SqlDbType.Decimal,9),
					new SqlParameter("@ljzd", SqlDbType.Decimal,9),
					new SqlParameter("@ljzzd", SqlDbType.Decimal,9),
					new SqlParameter("@fssum", SqlDbType.Decimal,9),
					new SqlParameter("@fsqd", SqlDbType.Decimal,9),
					new SqlParameter("@fszd", SqlDbType.Decimal,9),
					new SqlParameter("@fszzd", SqlDbType.Decimal,9),
					new SqlParameter("@tbcnew", SqlDbType.Decimal,9),
					new SqlParameter("@yjzh", SqlDbType.Decimal,9),
					new SqlParameter("@fsrate", SqlDbType.Decimal,9),
					new SqlParameter("@fztime", SqlDbType.DateTime),
					new SqlParameter("@workarea", SqlDbType.Decimal,9),
					new SqlParameter("@wghwork", SqlDbType.Decimal,9),
					new SqlParameter("@zja", SqlDbType.Decimal,9),
					new SqlParameter("@xja", SqlDbType.Decimal,9),
					new SqlParameter("@bda", SqlDbType.Decimal,9),
					new SqlParameter("@fla", SqlDbType.Decimal,9),
					new SqlParameter("@qttda", SqlDbType.Decimal,9),
					new SqlParameter("@zwyyja", SqlDbType.Decimal,9),
					new SqlParameter("@qtsfa", SqlDbType.Decimal,9),
					new SqlParameter("@fsfza", SqlDbType.Decimal,9),
					new SqlParameter("@wghhfa", SqlDbType.Decimal,9),
					new SqlParameter("@wlfza", SqlDbType.Decimal,9),
					new SqlParameter("@rgfza", SqlDbType.Decimal,9),
					new SqlParameter("@qtfza", SqlDbType.Decimal,9),
					new SqlParameter("@qtwgha", SqlDbType.Decimal,9),
					new SqlParameter("@hxfza", SqlDbType.Decimal,9),
					new SqlParameter("@fzsum", SqlDbType.Decimal,9),
					new SqlParameter("@yfarea", SqlDbType.Decimal,9),
					new SqlParameter("@ffarea", SqlDbType.Decimal,9),
					new SqlParameter("@zjb", SqlDbType.Decimal,9),
					new SqlParameter("@xjb", SqlDbType.Decimal,9),
					new SqlParameter("@bdb", SqlDbType.Decimal,9),
					new SqlParameter("@flb", SqlDbType.Decimal,9),
					new SqlParameter("@qttdb", SqlDbType.Decimal,9),
					new SqlParameter("@qtsfb", SqlDbType.Decimal,9),
					new SqlParameter("@fsb", SqlDbType.Decimal,9),
					new SqlParameter("@rgb", SqlDbType.Decimal,9),
					new SqlParameter("@qtfzb", SqlDbType.Decimal,9),
					new SqlParameter("@hfb", SqlDbType.Decimal,9),
					new SqlParameter("@tbcxfz", SqlDbType.Decimal,9),
					new SqlParameter("@wghfzrate", SqlDbType.Decimal,9),
					new SqlParameter("@fzrate", SqlDbType.Decimal,9),
					new SqlParameter("@czarea", SqlDbType.Decimal,9),
					new SqlParameter("@whzharea", SqlDbType.Decimal,9),
					new SqlParameter("@czrate", SqlDbType.Decimal,9),
					new SqlParameter("@fzfy", SqlDbType.Decimal,9),
					new SqlParameter("@sszs", SqlDbType.Int,4),
					new SqlParameter("@zjl", SqlDbType.Decimal,9),
					new SqlParameter("@xjl", SqlDbType.Decimal,9),
					new SqlParameter("@bdl", SqlDbType.Decimal,9),
					new SqlParameter("@tdkc", SqlDbType.Decimal,9),
					new SqlParameter("@fsyl", SqlDbType.Decimal,9),
					new SqlParameter("@yjll", SqlDbType.Decimal,9),
					new SqlParameter("@jzll", SqlDbType.Decimal,9),
					new SqlParameter("@yjl", SqlDbType.Decimal,9),
					new SqlParameter("@hxqt", SqlDbType.Decimal,9),
					new SqlParameter("@uid", SqlDbType.Int,4),
					new SqlParameter("@apid", SqlDbType.Int,4)};
			parameters[0].Value = model.aid;
			parameters[1].Value = model.dpid;
			parameters[2].Value = model.trees;
			parameters[3].Value = model.shouldarea;
			parameters[4].Value = model.jzarea;
			parameters[5].Value = model.jcarea;
			parameters[6].Value = model.generation;
			parameters[7].Value = model.dctime;
			parameters[8].Value = model.dckdgarea;
			parameters[9].Value = model.fbarea;
			parameters[10].Value = model.sdlj;
			parameters[11].Value = model.ljqd;
			parameters[12].Value = model.ljzd;
			parameters[13].Value = model.ljzzd;
			parameters[14].Value = model.fssum;
			parameters[15].Value = model.fsqd;
			parameters[16].Value = model.fszd;
			parameters[17].Value = model.fszzd;
			parameters[18].Value = model.tbcnew;
			parameters[19].Value = model.yjzh;
			parameters[20].Value = model.fsrate;
			parameters[21].Value = model.fztime;
			parameters[22].Value = model.workarea;
			parameters[23].Value = model.wghwork;
			parameters[24].Value = model.zja;
			parameters[25].Value = model.xja;
			parameters[26].Value = model.bda;
			parameters[27].Value = model.fla;
			parameters[28].Value = model.qttda;
			parameters[29].Value = model.zwyyja;
			parameters[30].Value = model.qtsfa;
			parameters[31].Value = model.fsfza;
			parameters[32].Value = model.wghhfa;
			parameters[33].Value = model.wlfza;
			parameters[34].Value = model.rgfza;
			parameters[35].Value = model.qtfza;
			parameters[36].Value = model.qtwgha;
			parameters[37].Value = model.hxfza;
			parameters[38].Value = model.fzsum;
			parameters[39].Value = model.yfarea;
			parameters[40].Value = model.ffarea;
			parameters[41].Value = model.zjb;
			parameters[42].Value = model.xjb;
			parameters[43].Value = model.bdb;
			parameters[44].Value = model.flb;
			parameters[45].Value = model.qttdb;
			parameters[46].Value = model.qtsfb;
			parameters[47].Value = model.fsb;
			parameters[48].Value = model.rgb;
			parameters[49].Value = model.qtfzb;
			parameters[50].Value = model.hfb;
			parameters[51].Value = model.tbcxfz;
			parameters[52].Value = model.wghfzrate;
			parameters[53].Value = model.fzrate;
			parameters[54].Value = model.czarea;
			parameters[55].Value = model.whzharea;
			parameters[56].Value = model.czrate;
			parameters[57].Value = model.fzfy;
			parameters[58].Value = model.sszs;
			parameters[59].Value = model.zjl;
			parameters[60].Value = model.xjl;
			parameters[61].Value = model.bdl;
			parameters[62].Value = model.tdkc;
			parameters[63].Value = model.fsyl;
			parameters[64].Value = model.yjll;
			parameters[65].Value = model.jzll;
			parameters[66].Value = model.yjl;
			parameters[67].Value = model.hxqt;
			parameters[68].Value = model.uid;
			parameters[69].Value = model.apid;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int apid)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from addprevention ");
			strSql.Append(" where apid=@apid");
			SqlParameter[] parameters = {
					new SqlParameter("@apid", SqlDbType.Int,4)
			};
			parameters[0].Value = apid;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string apidlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from addprevention ");
			strSql.Append(" where apid in ("+apidlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public jnxc.Model.addprevention GetModel(int apid)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 apid,aid,dpid,trees,shouldarea,jzarea,jcarea,generation,dctime,dckdgarea,fbarea,sdlj,ljqd,ljzd,ljzzd,fssum,fsqd,fszd,fszzd,tbcnew,yjzh,fsrate,fztime,workarea,wghwork,zja,xja,bda,fla,qttda,zwyyja,qtsfa,fsfza,wghhfa,wlfza,rgfza,qtfza,qtwgha,hxfza,fzsum,yfarea,ffarea,zjb,xjb,bdb,flb,qttdb,qtsfb,fsb,rgb,qtfzb,hfb,tbcxfz,wghfzrate,fzrate,czarea,whzharea,czrate,fzfy,sszs,zjl,xjl,bdl,tdkc,fsyl,yjll,jzll,yjl,hxqt,uid from addprevention ");
			strSql.Append(" where apid=@apid");
			SqlParameter[] parameters = {
					new SqlParameter("@apid", SqlDbType.Int,4)
			};
			parameters[0].Value = apid;

			jnxc.Model.addprevention model=new jnxc.Model.addprevention();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public jnxc.Model.addprevention DataRowToModel(DataRow row)
		{
			jnxc.Model.addprevention model=new jnxc.Model.addprevention();
			if (row != null)
			{
				if(row["apid"]!=null && row["apid"].ToString()!="")
				{
					model.apid=int.Parse(row["apid"].ToString());
				}
				if(row["aid"]!=null && row["aid"].ToString()!="")
				{
					model.aid=int.Parse(row["aid"].ToString());
				}
				if(row["dpid"]!=null && row["dpid"].ToString()!="")
				{
					model.dpid=int.Parse(row["dpid"].ToString());
				}
				if(row["trees"]!=null)
				{
					model.trees=row["trees"].ToString();
				}
				if(row["shouldarea"]!=null && row["shouldarea"].ToString()!="")
				{
					model.shouldarea=decimal.Parse(row["shouldarea"].ToString());
				}
				if(row["jzarea"]!=null && row["jzarea"].ToString()!="")
				{
					model.jzarea=decimal.Parse(row["jzarea"].ToString());
				}
				if(row["jcarea"]!=null && row["jcarea"].ToString()!="")
				{
					model.jcarea=decimal.Parse(row["jcarea"].ToString());
				}
				if(row["generation"]!=null && row["generation"].ToString()!="")
				{
					model.generation=int.Parse(row["generation"].ToString());
				}
				if(row["dctime"]!=null && row["dctime"].ToString()!="")
				{
					model.dctime=DateTime.Parse(row["dctime"].ToString());
				}
				if(row["dckdgarea"]!=null && row["dckdgarea"].ToString()!="")
				{
					model.dckdgarea=decimal.Parse(row["dckdgarea"].ToString());
				}
				if(row["fbarea"]!=null && row["fbarea"].ToString()!="")
				{
					model.fbarea=decimal.Parse(row["fbarea"].ToString());
				}
				if(row["sdlj"]!=null && row["sdlj"].ToString()!="")
				{
					model.sdlj=decimal.Parse(row["sdlj"].ToString());
				}
				if(row["ljqd"]!=null && row["ljqd"].ToString()!="")
				{
					model.ljqd=decimal.Parse(row["ljqd"].ToString());
				}
				if(row["ljzd"]!=null && row["ljzd"].ToString()!="")
				{
					model.ljzd=decimal.Parse(row["ljzd"].ToString());
				}
				if(row["ljzzd"]!=null && row["ljzzd"].ToString()!="")
				{
					model.ljzzd=decimal.Parse(row["ljzzd"].ToString());
				}
				if(row["fssum"]!=null && row["fssum"].ToString()!="")
				{
					model.fssum=decimal.Parse(row["fssum"].ToString());
				}
				if(row["fsqd"]!=null && row["fsqd"].ToString()!="")
				{
					model.fsqd=decimal.Parse(row["fsqd"].ToString());
				}
				if(row["fszd"]!=null && row["fszd"].ToString()!="")
				{
					model.fszd=decimal.Parse(row["fszd"].ToString());
				}
				if(row["fszzd"]!=null && row["fszzd"].ToString()!="")
				{
					model.fszzd=decimal.Parse(row["fszzd"].ToString());
				}
				if(row["tbcnew"]!=null && row["tbcnew"].ToString()!="")
				{
					model.tbcnew=decimal.Parse(row["tbcnew"].ToString());
				}
				if(row["yjzh"]!=null && row["yjzh"].ToString()!="")
				{
					model.yjzh=decimal.Parse(row["yjzh"].ToString());
				}
				if(row["fsrate"]!=null && row["fsrate"].ToString()!="")
				{
					model.fsrate=decimal.Parse(row["fsrate"].ToString());
				}
				if(row["fztime"]!=null && row["fztime"].ToString()!="")
				{
					model.fztime=DateTime.Parse(row["fztime"].ToString());
				}
				if(row["workarea"]!=null && row["workarea"].ToString()!="")
				{
					model.workarea=decimal.Parse(row["workarea"].ToString());
				}
				if(row["wghwork"]!=null && row["wghwork"].ToString()!="")
				{
					model.wghwork=decimal.Parse(row["wghwork"].ToString());
				}
				if(row["zja"]!=null && row["zja"].ToString()!="")
				{
					model.zja=decimal.Parse(row["zja"].ToString());
				}
				if(row["xja"]!=null && row["xja"].ToString()!="")
				{
					model.xja=decimal.Parse(row["xja"].ToString());
				}
				if(row["bda"]!=null && row["bda"].ToString()!="")
				{
					model.bda=decimal.Parse(row["bda"].ToString());
				}
				if(row["fla"]!=null && row["fla"].ToString()!="")
				{
					model.fla=decimal.Parse(row["fla"].ToString());
				}
				if(row["qttda"]!=null && row["qttda"].ToString()!="")
				{
					model.qttda=decimal.Parse(row["qttda"].ToString());
				}
				if(row["zwyyja"]!=null && row["zwyyja"].ToString()!="")
				{
					model.zwyyja=decimal.Parse(row["zwyyja"].ToString());
				}
				if(row["qtsfa"]!=null && row["qtsfa"].ToString()!="")
				{
					model.qtsfa=decimal.Parse(row["qtsfa"].ToString());
				}
				if(row["fsfza"]!=null && row["fsfza"].ToString()!="")
				{
					model.fsfza=decimal.Parse(row["fsfza"].ToString());
				}
				if(row["wghhfa"]!=null && row["wghhfa"].ToString()!="")
				{
					model.wghhfa=decimal.Parse(row["wghhfa"].ToString());
				}
				if(row["wlfza"]!=null && row["wlfza"].ToString()!="")
				{
					model.wlfza=decimal.Parse(row["wlfza"].ToString());
				}
				if(row["rgfza"]!=null && row["rgfza"].ToString()!="")
				{
					model.rgfza=decimal.Parse(row["rgfza"].ToString());
				}
				if(row["qtfza"]!=null && row["qtfza"].ToString()!="")
				{
					model.qtfza=decimal.Parse(row["qtfza"].ToString());
				}
				if(row["qtwgha"]!=null && row["qtwgha"].ToString()!="")
				{
					model.qtwgha=decimal.Parse(row["qtwgha"].ToString());
				}
				if(row["hxfza"]!=null && row["hxfza"].ToString()!="")
				{
					model.hxfza=decimal.Parse(row["hxfza"].ToString());
				}
				if(row["fzsum"]!=null && row["fzsum"].ToString()!="")
				{
					model.fzsum=decimal.Parse(row["fzsum"].ToString());
				}
				if(row["yfarea"]!=null && row["yfarea"].ToString()!="")
				{
					model.yfarea=decimal.Parse(row["yfarea"].ToString());
				}
				if(row["ffarea"]!=null && row["ffarea"].ToString()!="")
				{
					model.ffarea=decimal.Parse(row["ffarea"].ToString());
				}
				if(row["zjb"]!=null && row["zjb"].ToString()!="")
				{
					model.zjb=decimal.Parse(row["zjb"].ToString());
				}
				if(row["xjb"]!=null && row["xjb"].ToString()!="")
				{
					model.xjb=decimal.Parse(row["xjb"].ToString());
				}
				if(row["bdb"]!=null && row["bdb"].ToString()!="")
				{
					model.bdb=decimal.Parse(row["bdb"].ToString());
				}
				if(row["flb"]!=null && row["flb"].ToString()!="")
				{
					model.flb=decimal.Parse(row["flb"].ToString());
				}
				if(row["qttdb"]!=null && row["qttdb"].ToString()!="")
				{
					model.qttdb=decimal.Parse(row["qttdb"].ToString());
				}
				if(row["qtsfb"]!=null && row["qtsfb"].ToString()!="")
				{
					model.qtsfb=decimal.Parse(row["qtsfb"].ToString());
				}
				if(row["fsb"]!=null && row["fsb"].ToString()!="")
				{
					model.fsb=decimal.Parse(row["fsb"].ToString());
				}
				if(row["rgb"]!=null && row["rgb"].ToString()!="")
				{
					model.rgb=decimal.Parse(row["rgb"].ToString());
				}
				if(row["qtfzb"]!=null && row["qtfzb"].ToString()!="")
				{
					model.qtfzb=decimal.Parse(row["qtfzb"].ToString());
				}
				if(row["hfb"]!=null && row["hfb"].ToString()!="")
				{
					model.hfb=decimal.Parse(row["hfb"].ToString());
				}
				if(row["tbcxfz"]!=null && row["tbcxfz"].ToString()!="")
				{
					model.tbcxfz=decimal.Parse(row["tbcxfz"].ToString());
				}
				if(row["wghfzrate"]!=null && row["wghfzrate"].ToString()!="")
				{
					model.wghfzrate=decimal.Parse(row["wghfzrate"].ToString());
				}
				if(row["fzrate"]!=null && row["fzrate"].ToString()!="")
				{
					model.fzrate=decimal.Parse(row["fzrate"].ToString());
				}
				if(row["czarea"]!=null && row["czarea"].ToString()!="")
				{
					model.czarea=decimal.Parse(row["czarea"].ToString());
				}
				if(row["whzharea"]!=null && row["whzharea"].ToString()!="")
				{
					model.whzharea=decimal.Parse(row["whzharea"].ToString());
				}
				if(row["czrate"]!=null && row["czrate"].ToString()!="")
				{
					model.czrate=decimal.Parse(row["czrate"].ToString());
				}
				if(row["fzfy"]!=null && row["fzfy"].ToString()!="")
				{
					model.fzfy=decimal.Parse(row["fzfy"].ToString());
				}
				if(row["sszs"]!=null && row["sszs"].ToString()!="")
				{
					model.sszs=int.Parse(row["sszs"].ToString());
				}
				if(row["zjl"]!=null && row["zjl"].ToString()!="")
				{
					model.zjl=decimal.Parse(row["zjl"].ToString());
				}
				if(row["xjl"]!=null && row["xjl"].ToString()!="")
				{
					model.xjl=decimal.Parse(row["xjl"].ToString());
				}
				if(row["bdl"]!=null && row["bdl"].ToString()!="")
				{
					model.bdl=decimal.Parse(row["bdl"].ToString());
				}
				if(row["tdkc"]!=null && row["tdkc"].ToString()!="")
				{
					model.tdkc=decimal.Parse(row["tdkc"].ToString());
				}
				if(row["fsyl"]!=null && row["fsyl"].ToString()!="")
				{
					model.fsyl=decimal.Parse(row["fsyl"].ToString());
				}
				if(row["yjll"]!=null && row["yjll"].ToString()!="")
				{
					model.yjll=decimal.Parse(row["yjll"].ToString());
				}
				if(row["jzll"]!=null && row["jzll"].ToString()!="")
				{
					model.jzll=decimal.Parse(row["jzll"].ToString());
				}
				if(row["yjl"]!=null && row["yjl"].ToString()!="")
				{
					model.yjl=decimal.Parse(row["yjl"].ToString());
				}
				if(row["hxqt"]!=null && row["hxqt"].ToString()!="")
				{
					model.hxqt=decimal.Parse(row["hxqt"].ToString());
				}
				if(row["uid"]!=null && row["uid"].ToString()!="")
				{
					model.uid=int.Parse(row["uid"].ToString());
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select apid,aid,dpid,trees,shouldarea,jzarea,jcarea,generation,dctime,dckdgarea,fbarea,sdlj,ljqd,ljzd,ljzzd,fssum,fsqd,fszd,fszzd,tbcnew,yjzh,fsrate,fztime,workarea,wghwork,zja,xja,bda,fla,qttda,zwyyja,qtsfa,fsfza,wghhfa,wlfza,rgfza,qtfza,qtwgha,hxfza,fzsum,yfarea,ffarea,zjb,xjb,bdb,flb,qttdb,qtsfb,fsb,rgb,qtfzb,hfb,tbcxfz,wghfzrate,fzrate,czarea,whzharea,czrate,fzfy,sszs,zjl,xjl,bdl,tdkc,fsyl,yjll,jzll,yjl,hxqt,uid ");
			strSql.Append(" FROM addprevention ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" apid,aid,dpid,trees,shouldarea,jzarea,jcarea,generation,dctime,dckdgarea,fbarea,sdlj,ljqd,ljzd,ljzzd,fssum,fsqd,fszd,fszzd,tbcnew,yjzh,fsrate,fztime,workarea,wghwork,zja,xja,bda,fla,qttda,zwyyja,qtsfa,fsfza,wghhfa,wlfza,rgfza,qtfza,qtwgha,hxfza,fzsum,yfarea,ffarea,zjb,xjb,bdb,flb,qttdb,qtsfb,fsb,rgb,qtfzb,hfb,tbcxfz,wghfzrate,fzrate,czarea,whzharea,czrate,fzfy,sszs,zjl,xjl,bdl,tdkc,fsyl,yjll,jzll,yjl,hxqt,uid ");
			strSql.Append(" FROM addprevention ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM Vaddprevention ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.apid desc");
			}
			strSql.Append(")AS Row, T.*  from Vaddprevention T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "addprevention";
			parameters[1].Value = "apid";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

